<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 方法一
      // var arr = [11,23,33,42,1,0,2,9]
      // var newArr = []
      // var j = 0
      // for (var i = 0 ; i<arr.length; i++) {
      //     if (arr[i] > 10) {
      //         newArr[j] = arr[i]
      //         j++
      //     }
      // }
      // console.log(newArr);

    //   方法二
    //   var arr = [11, 23, 33, 42, 1, 0, 2, 9]
    //   var newArr = []
    //   for (var i = 0; i < arr.length; i++) {
    //     if (arr[i] >= 10) {
    //       newArr.push(arr[i])
    //     }
    //   }
    //   console.log(newArr)


    // 方法三
    var arr = [11, 23, 33, 42, 1, 0, 2, 9]
    var newArr = []
    for (var i = 0 ; i < arr.length ; i++) {
        if (arr[i] >= 10) {
            newArr[newArr.length] = arr[i]
        }
    }
    console.log(newArr);





    </script>
  </body>
</html>
